var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GameConstant"),
s = t("BroadCastMessage"),
l = t("Util"),
c = cc._decorator,
d = c.ccclass,
h = c.property,
p = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.spine = null,
        e.node_collider = null,
        e.boxcollider = null,
        e.phyBoxCollider = null,
        e.pfb_star = null,
        e.damageNum = 0,
        e.bGameStart = !1,
        e.nCurOrient = r.Car_Orientation.Default,
        e.bCanAttack = !0,
        e.bCanDamage = !1,
        e.bPlayAnim = !0,
        e
    }
    return n(e, t),
    e.prototype.init = function(t, e, o, i) {
        this.boxcollider.tag = e,
        this.phyBoxCollider.tag = e,
        this.phyBoxCollider.node.active = !1,
        this.node_collider.active = !1,
        this.damageNum = o,
        this._carTag = t,
        t == r.Collide_Car_Tag.Left ? (this.nCurOrient = r.Car_Orientation.Right, this.node.scaleX = 1, this.node.position = i) : (this.nCurOrient = r.Car_Orientation.Left, this.node.scaleX = -1, this.node.position = cc.v3( - i.x, i.y, i.z))
    },
    e.prototype.onGameStart = function() {},
    e.prototype.onGameOver = function() {
        this.bGameStart = !1,
        this.spine.paused = !0,
        this.bCanDamage = !1
    },
    e.prototype.onGameBoutReady = function() {
        this.unscheduleAllCallbacks(),
        this.node.active = !1,
        this.destroy()
    },
    e.prototype.onGameBoutStart = function() {
        this.bGameStart = !0,
        this.playAni()
    },
    e.prototype.onGameBoutOver = function() {
        this.bGameStart = !1,
        this.spine.paused = !0,
        this.bCanDamage = !1
    },
    e.prototype.onCanAttack = function(t) {
        this.bCanAttack = t,
        t ? (this.node.stopAllActions(), this.playAni()) : this.node.stopAllActions()
    },
    e.prototype.onMoveLeft = function() {
        this.nCurOrient != r.Car_Orientation.Left && (this.nCurOrient = r.Car_Orientation.Left, this.phyBoxCollider.node.active = !1, this.onCDPlayAni())
    },
    e.prototype.onMoveRight = function() {
        this.nCurOrient != r.Car_Orientation.Right && (this.nCurOrient = r.Car_Orientation.Right, this.phyBoxCollider.node.active = !1, this.onCDPlayAni())
    },
    e.prototype.onCDPlayAni = function() {
        var t = this;
        this.bPlayAnim = !1,
        this.node.stopAllActions(),
        cc.tween(this.node).delay(.25).call(function() {
            t.bPlayAnim = !0,
            t.playAni()
        }).start()
    },
    e.prototype.playAni = function() {
        var t = this;
        this.bCanAttack && this.bGameStart && this.bPlayAnim && (this.bCanDamage = !0, this.spine.setAnimation(0, "animation", !1), this.node_collider.active = !0, this.node_collider.getComponent(cc.Animation).play(), cc.tween(this.node).delay(.02).call(function() {
            t.boxcollider.node.active = !0,
            t.phyBoxCollider.node.active = !0
        }).delay(.2).call(function() {
            t.boxcollider.node.active = !1,
            t.phyBoxCollider.node.active = !1,
            t.bCanDamage = !1
        }).delay(l.Util.attackSpeed(.75, this._carTag)).call(function() {
            t.playAni()
        }).start())
    },
    e.prototype.playEffect = function() {
        this.bGameStart
    },
    e.prototype.getDamage = function() {
        return this.bCanDamage ? (this.bCanDamage = !1, this.boxcollider.node.active = !1, l.Util.vibrateMiddle(), this.playAudio(), this.damageNum) : 0
    },
    e.prototype.playAudio = function() {
        s.default.getInstance().SendMessage(r.Game_Broadcast_Func.Audio, r.Game_Audio_ID.fist_hit)
    },
    a([h(sp.Skeleton)], e.prototype, "spine", void 0),
    a([h(cc.Node)], e.prototype, "node_collider", void 0),
    a([h(cc.Collider)], e.prototype, "boxcollider", void 0),
    a([h(cc.PhysicsBoxCollider)], e.prototype, "phyBoxCollider", void 0),
    a([h(cc.Prefab)], e.prototype, "pfb_star", void 0),
    a([d], e)
} (cc.Component);
o.default = p